/**
 * 
 */
package qy.jalgotrade.broker.backtesting;

import java.time.ZonedDateTime;

import qy.jalgotrade.bar.Bar;
import qy.jalgotrade.broker.InstrumentTraits;
import qy.jalgotrade.broker.LimitOrder;
import qy.jalgotrade.broker.fillstrategy.FillInfo;

/**
 * @author c-geo
 *
 */
public class BacktestingLimitOrder extends LimitOrder implements BacktestingOrder {

	private ZonedDateTime __accepted;

	/**
	 * @param action
	 * @param instrument
	 * @param limitPrice
	 * @param quantity
	 * @param instrumentTraits
	 * @throws Exception
	 */
	public BacktestingLimitOrder(Action action, String instrument, double limitPrice, double quantity,
	        InstrumentTraits instrumentTraits) throws Exception {

		super(action, instrument, limitPrice, quantity, instrumentTraits);
		__accepted = null;
	}

	/* (non-Javadoc)
	 * @see qy.jalgotrade.broker.backtesting.BacktestingOrder#getAcceptedDateTime()
	 */
	@Override
	public ZonedDateTime getAcceptedDateTime() {

		return __accepted;
	}

	/* (non-Javadoc)
	 * @see qy.jalgotrade.broker.backtesting.BacktestingOrder#setAcceptedDateTime(java.time.ZonedDateTime)
	 */
	@Override
	public void setAcceptedDateTime(ZonedDateTime dateTime) {

		__accepted = dateTime;
	}

	/* (non-Javadoc)
	 * @see qy.jalgotrade.broker.backtesting.BacktestingOrder#process(qy.jalgotrade.broker.backtesting.BacktestingBroker, qy.jalgotrade.bar.Bar)
	 */
	@Override
	public FillInfo process(BacktestingBroker broker, Bar bar) {

		return broker.getFillStrategy().fillLimitOrder(broker, this, bar);
	}
}
